// Pages/detailPageSell/detailPageSell.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    thingsId:'',

    images:[],
    id: 1,
    thingName: "",
    descri: "",
    price: "",
    exchangeable: "",
    publishDate: "",
    newOld: "",
    account: "",
    name: "",
    department: "",
    userId: '',
    weixin: "",
    mobile: "",
    photo:'',
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    console.log(options.thingsId)
    that.setData({
      thingsId: options.thingsId//接受到上一个页面传过来的商品id、
    })
 
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getDataDetial(this.data.thingsId);
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
,
  getDataDetial:function(str){
    var that = this
    var id=str
    
    var api = "http://47.103.21.65:5645/sell/getSellDetail";

    // if (that.data.activeIndex == 1) {
    //   api = "http://47.103.21.65:5645/require/getRequireListByType";
    // }

    wx.request({
      url: api,
      method: "GET",

      data: {  //参数传递
        sellId:id
      },
      header: { //设置请求头
        'content-type': 'application/x-www-form-urlencoded',// 默认值//header:{...}用啥设置啥，

      },

      success: function (res) {
        console.log(res.data.data.images);
        that.setData({
          images: res.data.data.images,
          id: res.data.data.info.id,
          thingName: res.data.data.info.thingName,
          descri: res.data.data.info.descri, 
          price:res.data.data.info.price,
          exchangeable: res.data.data.info.exchangeable,
          publishDate: res.data.data.info.publishDate,
          newOld: res.data.data.info.newOld,
          account: res.data.data.info.account,
          name: res.data.data.info.name,
          department: res.data.data.info.department,
          userId: res.data.data.info.userId,
          weixin: res.data.data.info.weixin,
          mobile: res.data.data.info.mobile,
          photo:res.data.data.info.photo
        })
        

      },
      fail: function (error) { //请求失败
        console.log(error);

      }
    })
  },
  tobuying:function(){
    console.log(this.data.thingsId+"222222")
    wx.navigateTo({
      url: '../business/bussiness?thingsId='+this.data.thingsId,
    })
  }
})
